package com.shoujifeng.snowmusic.player.http;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class ServerAccess {
	public final static String GET_NEWS_INDEX = "Get_News_Index";

	public final static String GET_NEWS_CONTENT = "Get_News_Content";
	public final static String NEWS_TABLE_NAME = "EJa_News";

	public final static String USER_ID = "UserID";
	public final static String HOT_MUSIC_LIST = "hot_music_list";
	public static final String CHARTS_MUSIC_LIST = "charts_music_list";
	public static final String MORE_SINGER = "hot_singer";
	public static final String ADV_LIST = "adv_list";
	public static final String APP_LIST = "app_list";
	public static final String MORE_MUSIC = "more_music";
	public static final String MORE_SPECIAL = "more_special";
	public static final String MORE_NEW_MUSCI = "more_new_music";
	public static final String GROUP_MUSIC_LIST = "group_music_list";
	public static final String GROUP_LIST = "group_list";
	public static final String MORE_NEW_MUSCI_MENU = "more_new_music_menu";
	public final static String MAIN = "main";
	public final static String NEW = "new";
	public final static String MUSIC_ALBUM = "music_album";
	public final static String SEARCH = "search";
	public final static String PAGE = "page";
	public final static String MUSIC = "music";
	public final static String MUSIC_NAME = "name";
	public final static String ID = "id";
	public final static String MID = "mid";
	public final static String CHARTS_LIST = "charts_list";
	public final static String SINGER = "singer";
	public final static String ICON_URL = "icon_url";
	public final static String INDEX = "index";
	public final static String CODE = "code";
	public static final String FACEDRAWABLE = "facedrawble";
	public static final String ALBUM = "album";
	public static final String LISTENER = "listener";
	public static final String ALBUM_MUSIC_LIST = "album_music_list";
	public static final String SINGER_LIST = "singer_list";
	public static final String FILE = "file";
	public static final String FILE_URL = "file_url";
	public static final String STATE = "state";
	public static final String SINGER_MUSIC_LIST = "singer_music_list";
	public static final String MUSIC_FILE = "music_file";
	public static final String CONTENT = "content";
	public static final String ARTIST_ID = "artist_id";
	public static final String GROUP = "group";
	public static final String NUMBER = "number";
	public static final String PASSWORD = "password";
	public static final String URL = "url";
	public static final String LOGIN = "login";
	public static final String VIEWS = "views";
	public static final String LAN = "lan";
	public static final String FACE = "face";
	public static final String NICKNAME = "nickname";
	public static final String UID = "uid";
	public static final String SET_STOP_TIME = "set_stop_time";
	public static final String SET_TIME = "set_time";
	public final static String SET_WIFI = "set_wifi"; // 设置wifi
	public final static String PRO	= "pro";
	public final static String PRO_MAX	= "pro_max";
	public final static String GETALBUMID	= "getAlbumId";
	public final static String GETSINGERID	= "getSingerId";
	public final static String ADV_MUSIC_LIST = "adv_music_list";
	public final static String PUSH = "push";
	public static boolean AddOneMusicToMenu =  false;
	public static HashMap<String, Object>  musicMap= new HashMap<String, Object>();
	
	
	
	
	//登陆信息
	public static String code = "";
	public static String number = "";
	public static String nickname = "";
	public static long uid = 0;
	
	public static String activityName = "";
	
	public static int  netListCount = 0;

	private PostAccess mPostAccess;

	// 接口信息
	private final String ONLINE_ADD_CONLLECT = "http://www.snowmusic.com.cn/mobile_api/add_conllect.php";
	private final String ONLINE_DEL_CONLLECT = "http://www.snowmusic.com.cn/mobile_api/del_conllect.php";
	private final String ONLINE_CONLLECT_LIST = "http://www.snowmusic.com.cn/mobile_api/conllect_list.php";
	private final String ONLINE_APP_MSG = "http://www.snowmusic.com.cn/check_version_android.php";
	private final String ONLINE_ADVICES = "http://www.snowmusic.com.cn/mobile_api/advices.php";
	private final String ONLINE_LRC = "http://www.snowmusic.com.cn/mobile_api/music_lrc.php";
	
	public ServerAccess(Context context) {
		mPostAccess = new PostAccess();
	}

	// 判断是否连接wifi
	public static boolean checkNetworkConnection(Context context) {
		ConnectivityManager connMgr = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo mWifi = connMgr
				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		if (mWifi.isConnected()) {
			return true;
		} else {
			return false;
		}
	}

	// 获取热歌列表
	public ArrayList<HashMap<String, Object>> getHotMusicListOfIndex(
			String[] keys, int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { PAGE },
				new String[] { Integer.toString(page) },
				GlobalValue.getUrl(HOT_MUSIC_LIST));

		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);

		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				

			}
			array.add(map);
		}

		return array;
	}

	// 获取专辑列表
	public ArrayList<HashMap<String, Object>> getSpecialListOfIndex(
			String[] keys, int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { PAGE },
				new String[] { Integer.toString(page) },
				GlobalValue.getUrl(MUSIC_ALBUM));

		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(ALBUM);

		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "《"+jsonObject.getString(keys[j])+"》");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				
				
			}
			array.add(map);
		}

		return array;
	}

	// 获取在线专辑中的歌曲列表
	public ArrayList<HashMap<String, Object>> getAlbumMusicList(String[] keys,
			String index, String singer, int page,String album) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { PAGE, INDEX },
				new String[] { Integer.toString(page), index },
				GlobalValue.getUrl(ALBUM_MUSIC_LIST));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if (keys[j].equals("singer")) {
					map.put(keys[j], singer);
				}else
					if(keys[j].equals(ServerAccess.ALBUM)){
						map.put(keys[j], album.substring(1, album.length()-1));
				} 
				else {
					map.put(keys[j], jsonObject.getString(keys[j]));
				}

			}
			array.add(map);
		}
		return array;
	}

	// 获取在线歌手列表
	public ArrayList<HashMap<String, Object>> getSingerListByState(
			String[] keys, String index, int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { PAGE, INDEX },
				new String[] { Integer.toString(page), index },
				GlobalValue.getUrl(SINGER_LIST));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(SINGER);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 获取在线歌手的歌曲列表
	public ArrayList<HashMap<String, Object>> getMusicListBySinger(
			String[] keys, String index, int page, String singer)
			throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { PAGE, INDEX },
				new String[] { Integer.toString(page), index },
				GlobalValue.getUrl(SINGER_MUSIC_LIST));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if (keys[j].equals("singer")) {
					map.put(keys[j], singer);
				}
				else if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else {
					map.put(keys[j], jsonObject.getString(keys[j]));
				}

			}
			array.add(map);
		}
		return array;
	}

	// 获取首页单曲推荐
	public ArrayList<HashMap<String, Object>> getMusicListAtFirstPage(
			String[] keys) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(MAIN));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				

			}
			array.add(map);
		}
		return array;
	}

	// 获取首页专辑推荐
	public ArrayList<HashMap<String, Object>> getAlbumListAtFirstPage(
			String[] keys) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(MAIN));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(ALBUM);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 获取首页专辑推荐
	public ArrayList<HashMap<String, Object>> getNewListAtFirstPage(
			String[] keys) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(MAIN));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(NEW);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				

			}
			array.add(map);
		}
		return array;
	}

	// 获取首页专辑推荐
	public ArrayList<HashMap<String, Object>> getPlayerListAtFirstPage(
			String[] keys) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(MAIN));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(SINGER);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 获取热门歌单
	public ArrayList<HashMap<String, Object>> getHotListAtFirstPage(
			String[] keys) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(MAIN));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(GROUP);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 获取搜索专辑列表
	public ArrayList<HashMap<String, Object>> getAlbumListAtSearch(
			String[] keys, String content) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { SEARCH,
				PAGE }, new String[] { content, "0" },
				GlobalValue.getUrl(SEARCH));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(ALBUM);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "《"+jsonObject.getString(keys[j])+"》");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				

			}
			array.add(map);
		}
		return array;
	}

	// 获取搜索歌曲列表
	public ArrayList<HashMap<String, Object>> getMusicListAtSearch(
			String[] keys, String content) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { SEARCH,
				PAGE }, new String[] { content, "0" },
				GlobalValue.getUrl(SEARCH));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
				

			}
			array.add(map);
		}
		return array;
	}

	// 获取验证码
	public String getChecking(String number) throws JSONException {
		String jsonString = mPostAccess.sendPostData(new String[] { NUMBER },
				new String[] { number },
				"http://www.snowmusic.com.cn/mobile_api/vcode.php");
		// {"code":"921152","code_type":1,"phone":"18312831341","create_time":1389076446}
		JSONObject jsonArray = new JSONObject(jsonString);
		String code = jsonArray.getString("code");
		return code;
	}

	// 登录
	public HashMap<String, Object> login(String number, String password)
			throws JSONException {

		String jsonString = mPostAccess.sendPostData(new String[] { NUMBER,
				PASSWORD }, new String[] { number, password },
				GlobalValue.getUrl(LOGIN));
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		JSONObject jsonArray = new JSONObject(jsonString);
		String code = jsonArray.getString("code");
		if(code.equals("1")) {
			String nickName = jsonArray.getString(NICKNAME);
			String uid = jsonArray.getString("userid");
			
			map.put(NICKNAME, nickName);
			map.put(USER_ID, uid);

		}
		map.put(CODE, code);

		return map;
	}

	// 注册
	public String register(String number, String password) throws JSONException {
		String jsonString = mPostAccess.sendPostData(new String[] { NUMBER,
				PASSWORD }, new String[] { number, password },
				"http://www.snowmusic.com.cn/mobile_api/regist.php");
		// "code_type":2,"code":2
		JSONObject jsonArray = new JSONObject(jsonString);
		String code = jsonArray.getString("code");
		return code;
	}

	// 修改密码
	public String revampPassword(String number, String password)
			throws JSONException {
		String jsonString = mPostAccess.sendPostData(new String[] { NUMBER,
				PASSWORD }, new String[] { number, password },
				"http://www.snowmusic.com.cn/mobile_api/forget.php");
		// "code_type":2,"code":2
		JSONObject jsonArray = new JSONObject(jsonString);
		String code = jsonArray.getString("code");
		return code;
	}

	// 榜单 1
	public ArrayList<HashMap<String, Object>> getOrderListTwo(String[] keys)
			throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(CHARTS_LIST));
		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("charts_34");
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 榜单 2
	public ArrayList<HashMap<String, Object>> getOrderListThree(String[] keys)
			throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(CHARTS_LIST));
		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("charts_35");
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 榜单 3
	public ArrayList<HashMap<String, Object>> getOrderListFour(String[] keys)
			throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(CHARTS_LIST));
		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("charts_19");
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 榜单 4
	public ArrayList<HashMap<String, Object>> getOrderListOne(String[] keys)
			throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(new String[] { INDEX },
				new String[] { "0" }, GlobalValue.getUrl(CHARTS_LIST));
		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("charts_20");
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 榜单中的内容
	public ArrayList<HashMap<String, Object>> getOrderListMusic(String[] keys,
			int page, String index) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { INDEX, PAGE },
				new String[] { index, Integer.toString(page) },
				GlobalValue.getUrl(CHARTS_MUSIC_LIST));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("music");
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				
				if(keys[j].equals(ServerAccess.ALBUM)){
					map.put(keys[j], "");
				}
				else{
					map.put(keys[j], jsonObject.getString(keys[j]));
				}
			}
			array.add(map);
		}
		return array;
	}

	// 首页歌手更多
	public ArrayList<HashMap<String, Object>> getListSingerMore(String[] keys,
			int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { INDEX, PAGE },
				new String[] { "0", Integer.toString(page) },
				GlobalValue.getUrl(MORE_SINGER));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(SINGER);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 首页歌手更多
	public ArrayList<HashMap<String, Object>> getListMusicMore(String[] keys,
			int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { INDEX, PAGE },
				new String[] { "0", Integer.toString(page) },
				GlobalValue.getUrl(MORE_MUSIC));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(MUSIC);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 首页专辑更多
	public ArrayList<HashMap<String, Object>> getListSpecialMore(String[] keys,
			int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { INDEX, PAGE },
				new String[] { "0", Integer.toString(page) },
				GlobalValue.getUrl(MORE_SPECIAL));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(ALBUM);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 首页专辑更多
	public ArrayList<HashMap<String, Object>> getListNewMusicMore(
			String[] keys, int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { INDEX, PAGE },
				new String[] { "0", Integer.toString(page) },
				GlobalValue.getUrl(MORE_NEW_MUSCI));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(NEW);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 首页热门歌单更多
	public ArrayList<HashMap<String, Object>> getListMusicMenuMore(
			String[] keys, int page) throws JSONException {
		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
		String jsonString = mPostAccess.sendPostData(
				new String[] { PAGE },
				new String[] { Integer.toString(page) },
				GlobalValue.getUrl(GROUP_LIST));
		JSONArray jsonArray = new JSONObject(jsonString).getJSONArray(GROUP);
		for (int i = 0; i < jsonArray.length(); i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 添加收藏
	public ArrayList<HashMap<String, Object>> addToConllect(int index, long uid,
			String[] keys) throws JSONException {

		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();

		String jsonString = mPostAccess.sendPostData(new String[] { INDEX,
				"uid" }, new String[] { index + "", uid + "" },
				ONLINE_ADD_CONLLECT);

		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("conllect");

		for (int i = 0; i < jsonArray.length(); i++) {

			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 删除收藏
	public ArrayList<HashMap<String, Object>> delToConllect(int index, long uid,
			String[] keys) throws JSONException {

		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();

		String jsonString = mPostAccess.sendPostData(new String[] { INDEX,
				"uid" }, new String[] { index + "", uid + "" },
				ONLINE_DEL_CONLLECT);

		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("conllect");

		for (int i = 0; i < jsonArray.length(); i++) {

			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			array.add(map);
		}
		return array;
	}

	// 获取收藏
	public ArrayList<HashMap<String, Object>> getConllect(long uid, int page,
			String[] keys) throws JSONException {

		ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();

		String jsonString = mPostAccess.sendPostData(new String[] { INDEX,
				PAGE}, new String[] { uid + "", page + "" },
				ONLINE_CONLLECT_LIST);

		JSONArray jsonArray = new JSONObject(jsonString)
				.getJSONArray("music");

		for (int i = 0; i < jsonArray.length(); i++) {

			HashMap<String, Object> map = new HashMap<String, Object>();
			JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
			for (int j = 0; j < keys.length; j++) {
				map.put(keys[j], jsonObject.getString(keys[j]));

			}
			
			map.put("album", "");
			array.add(map);
		}
		return array;
	}
	
	// 获取设置中的软件推送
		public ArrayList<HashMap<String, Object>> getAppList(String keys[]) throws JSONException {
			ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
			String jsonString = mPostAccess.sendPostData(
					new String[] { "type"},
					new String[] { "1"},
					GlobalValue.getUrl(APP_LIST));
			JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("app");
			for (int i = 0; i < jsonArray.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
				for (int j = 0; j < keys.length; j++) {
					map.put(keys[j], jsonObject.getString(keys[j]));

				}
				array.add(map);
			}
			return array;
		}
		// 获取在线中的广告
		public ArrayList<HashMap<String, Object>> getAdvList(String keys[],String type) throws JSONException {
			ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
			String jsonString = mPostAccess.sendPostData(
					new String[] { "type"},
					new String[] { type},
					GlobalValue.getUrl(ServerAccess.ADV_LIST));
			JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("adv");
			for (int i = 0; i < jsonArray.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
				for (int j = 0; j < keys.length; j++) {
					map.put(keys[j], jsonObject.getString(keys[j]));

				}
				array.add(map);
			}
			return array;
		}
		
		// 获取在线中的最顶部的广告内容
		public ArrayList<HashMap<String, Object>> getAdvContentList(String keys[],int page ,String index) throws JSONException {
			ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
;			String jsonString = mPostAccess.sendPostData(
					new String[] { PAGE,INDEX},
					new String[] { Integer.toString(page),index},
					GlobalValue.getUrl(ServerAccess.ADV_MUSIC_LIST));
			JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("music");
			for (int i = 0; i < jsonArray.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
				for (int j = 0; j < keys.length; j++) {
					map.put(keys[j], jsonObject.getString(keys[j]));

				}
				array.add(map);
			}
			return array;
		}	
		
		//本地音乐里查看专辑
				public  String GetAblumAtmusicPlay(String album)throws JSONException{
					String jsonString = mPostAccess.sendPostData(
							new String[] { "album"},
							new String[] { album },
							GlobalValue.getUrl(GETALBUMID));
					JSONObject jsonArray = new JSONObject(jsonString);
					String code = jsonArray.getString("code");
					if(code.equals("1")){
						return jsonArray.getString("index");
					}
					else{
						return "";
					}
				}
				//本地音乐里查看歌手
				public  String GetPlayerAtmusicPlay(String singer)throws JSONException{
					String jsonString = mPostAccess.sendPostData(
							new String[] { "singer"},
							new String[] { singer },
							GlobalValue.getUrl(GETSINGERID));
					JSONObject jsonArray = new JSONObject(jsonString);
					String code = jsonArray.getString("code");
					if(code.equals("1")){
						return jsonArray.getString("index");
					}
					else{
						return "";
					}
				}
	
				// 获取APP信息
				public ArrayList<HashMap<String, Object>> getAppMsg(
						String[] keys) throws JSONException {

					ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();

					String jsonString = mPostAccess.sendPostData(new String[] {}, new String[] {},
							ONLINE_APP_MSG);

					JSONArray jsonArray = new JSONObject(jsonString)
							.getJSONArray("version");

					for (int i = 0; i < jsonArray.length(); i++) {

						HashMap<String, Object> map = new HashMap<String, Object>();
						JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
						for (int j = 0; j < keys.length; j++) {
							map.put(keys[j], jsonObject.getString(keys[j]));

						}
						array.add(map);
					}
					return array;
				}
				
				// 提交用户反馈
				public void addIder(String content, String email) throws JSONException {
					mPostAccess.sendPostData(
							new String[] { "content", "mail"},
							new String[] { content, email},
							ONLINE_ADVICES);
					
				}
	//在线广告
		public ArrayList<HashMap<String, Object>> getListAdv(String type,String[] keys) throws JSONException {
					ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
					String jsonString = mPostAccess.sendPostData(
							new String[] { "type" },
							new String[] {type},
							GlobalValue.getUrl(ADV_LIST));  
					JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("adv");
					for (int i = 0; i < jsonArray.length(); i++) {
						HashMap<String, Object> map = new HashMap<String, Object>();
						JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
						for (int j = 0; j < keys.length; j++) {
							map.put(keys[j], jsonObject.getString(keys[j]));

						}
						array.add(map);
					}
					return array;
				}
				
		//	获取首页中热门歌单中的内页内容
		public ArrayList<HashMap<String, Object>> getHotListConetnt(String index,String[] keys,int page) throws JSONException {
			ArrayList<HashMap<String, Object>> array = new ArrayList<HashMap<String, Object>>();
			String jsonString = mPostAccess.sendPostData(
					new String[] { "index","page" },
					new String[] {index,Integer.toString(page)},
					GlobalValue.getUrl(GROUP_MUSIC_LIST));  
			JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("music");
			for (int i = 0; i < jsonArray.length(); i++) {
				HashMap<String, Object> map = new HashMap<String, Object>();
				JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
				for (int j = 0; j < keys.length; j++) {
					map.put(keys[j], jsonObject.getString(keys[j]));

				}
				array.add(map);
			}
			return array;
		}
		
		// 获得歌词网址
		public String getLrcUrl(int index) throws JSONException {
			String jsonString = mPostAccess.sendPostData(
					new String[] { INDEX},
					new String[] {index+""},
					ONLINE_LRC);
			String lrcString = "";
			JSONArray jsonArray = new JSONObject(jsonString).getJSONArray("lrc");
			for (int i = 0; i < jsonArray.length(); i++) {
				
				JSONObject jsonObject = ((JSONObject) jsonArray.opt(i));
				lrcString = jsonObject.getString("lrc");

			}
			
			return lrcString;
		}
		
		// 获得歌词网址
				public String getLrc(String lrc) throws JSONException {
					String jsonString = mPostAccess.sendPostData(
							new String[] { },
							new String[] {},
							lrc);
					return jsonString;
				}

}
